//标签数据
import { getValType } from '../utils'

//不同环境下的命令
export const envCmdList = {
  dev: [
    'cd /Users/zhaoyj/WorkPlace',
    'pwd',
    'npm run build:dev',
    'rm -rf dist.zip',
    'zip -r dist.zip dist',
    'upload.sh 8.130.43.148 /www/`curProjectName`',
    'open -a "Google Chrome" `devPath`'
  ],
  test: [
    'cd /Users/zhaoyj/WorkPlace',
    'pwd',
    'npm run build:test',
    'rm -rf dist.zip',
    'zip -r dist.zip dist',
    'upload.sh 8.130.43.148 /www/`curProjectName`',
    'open -a "Google Chrome" `testPath`'
  ]
}

//todo 这些数据需要放到缓存里面
export const flagData = {
  餐厅: [
    {
      name: 'AdminMange',
      flag: ['总部管理'],
      devPath: 'http://admin.xiqueque.com',
      testPath: 'https://admin.smartorderkiosk.com/'
    },
    {
      name: 'AgentManage',
      flag: ['代理商管理'],
      devPath: 'http://agent.xiqueque.com/',
      testPath: 'https://agent.smartorderkiosk.com/'
    },
    {
      name: 'SRMerchantFront',
      flag: ['商户端'],
      devPath: 'http://mini.xiqueque.com/home',
      testPath: 'https://client.smartorderkiosk.com'
    },
    {
      name: 'SRFront',
      flag: ['客户端'],
      devPath: 'http://k.xiqueque.com/#/welcome',
      testPath: 'http://k.smartorderkiosk.com/#/welcome'
    },
    { name: 'SRApp', flag: ['客户端APP'] }
  ],
  契合: [
    {
      name: 'qh_manage_front',
      flag: ['契合派管理后台'],
      devPath: 'http://matchmaker.xiqueque.com/admin/#/',
      testPath: 'https://admin.qihe.fit'
    },
    {
      name: 'matchmaker_front',
      flag: ['红娘端'],
      devPath: 'http://matchmaker.xiqueque.com',
      testPath: 'https://admin.qihe.fit/'
    }
  ],
  '营销1.0': [
    { name: '95598-website', flag: ['95598网站'] },
    { name: 'msb-app', flag: ['蒙速办'] },
    { name: 'uni-mdej-app', flag: ['蒙电e家'] },
    { name: 'wxpt-net', flag: ['微信公众号'] },
    { name: 'kfdp-vue', flag: ['客服大屏'] },
    { name: 'mdej-chat', flag: ['客服'] },
    { name: 'yk_ydzypt', flag: ['移动营销'] }
  ],
  electron: [
    { name: 'adb-client', flag: ['手机adb管理工具'] },
    { name: 'UEMActivate', flag: ['手机提权工具'] },
    'AdbClient.zip',
    'Electron_Project'
  ],
  uniapp: [{ name: 'wx-uniapp', flag: ['个人小程序'] }, 'Uni_Demo', 'Uni_Project']
}

//将标签数据对象转换成标签只有一个一级属性的对象
function convertFlagDataToFlagObj() {
  let flagDataObj = {}
  Object.entries(flagData).forEach(([key, value]) => {
    //遍历对象的属性
    value.forEach((item) => {
      let name = getValType(item) === 'String' ? item : item.name
      let flag = getValType(item) === 'String' ? [key] : [key, ...item.flag]
      let { devPath, testPath } = item
      flagDataObj[name] = flagDataObj[name] ? flagDataObj[name] : {}
      flagDataObj[name].flag = flagDataObj[name].flag ? flagDataObj[name].flag : []
      flagDataObj[name].flag = [...flagDataObj[name].flag, ...flag]
      flagDataObj[name].devPath = devPath
      flagDataObj[name].testPath = testPath
    })
  })
  return flagDataObj
}

//
export const flagDataObj = convertFlagDataToFlagObj()
